package com.example.shippxy.utils;

public class KeysUtils {
    private static final String[] strings = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    public static String getNewKey(){
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < 30; i++) {
            int index = (int)(Math.random()*36);
            buffer.append(strings[index]);
        }
        return buffer.toString();
    }

    /***
     *
     * @param key
     * @return
     */
    public static String getNewKey(String key){
        int random = (int)(Math.random()*30)+1;
        String start = key.substring(0,random);
        String end = key.substring(random+1);
        int index = (int)(Math.random()*36);
        return start+strings[index]+end;
    }

    public static void main(String[] args) {
        String key = "a01ce294b485d3f88c5e0dc683d894f7";
        System.out.println(key);
        System.out.println(getNewKey(key));
    }
}
